import { Characteristic } from 'react-native-ble-plx'
import { base64 } from '@pier88health/p8h-common'
import DeviceResponseParser from '@UTILS/DeviceResponseParser'

class DeviceConfigurationInfo {
  private serialNumber: Characteristic | null | undefined

  private deviceInfoBleResponse: Characteristic | null | undefined

  constructor(deviceInfoBleResponse: null | Characteristic | undefined, serialNumber: null | Characteristic | undefined) {
    this.serialNumber = serialNumber
    this.deviceInfoBleResponse = deviceInfoBleResponse
  }

  getDeviceInfo = () => {
    return DeviceResponseParser.parseDeviceInfo(base64.decode(this.deviceInfoBleResponse?.value))
  }

  getSerialNumber = () => {
    return DeviceResponseParser.parseSerialNumber(base64.decode(this.serialNumber?.value))
  }
}

export default DeviceConfigurationInfo
